import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_animation/login_page.dart';

void main() {
  runApp(MyApp());

}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      navigatorObservers: [
        MYNavigatorObserver(),
      ],
      theme: ThemeData(
        primarySwatch: _createMaterialColor(Colors.white),
      ),
      home: LoginPage(),
    );
  }

}


class MYNavigatorObserver extends NavigatorObserver{

  @override
  void didPush(Route route, Route? previousRoute) {
    // TODO: implement didPush
    super.didPush(route, previousRoute);
    print('didPush==============${route.settings.name}+++previousRoute===${previousRoute?.settings.name}');
    route.navigator!.canPop();
    SystemNavigator.pop();
  }



  @override
  void didPop(Route route, Route? previousRoute) {
    // TODO: implement didPop
    super.didPop(route, previousRoute);
    print('didPop=============${route.settings.name}+++previousRoute===${previousRoute?.settings.name}');
  }

}


MaterialColor _createMaterialColor(Color color) {
  List strengths = <double>[.05];
  Map<int, Color> swatch = <int, Color>{};
  final int r = color.red, g = color.green, b = color.blue;

  for (int i = 1; i < 10; i++) {
    strengths.add(0.1 * i);
  }
  strengths.forEach((strength) {
    final double ds = 0.5 - strength;
    swatch[(strength * 1000).round()] = Color.fromRGBO(
      r + ((ds < 0 ? r : (255 - r)) * ds).round(),
      g + ((ds < 0 ? g : (255 - g)) * ds).round(),
      b + ((ds < 0 ? b : (255 - b)) * ds).round(),
      1,
    );
  });
  return MaterialColor(color.value, swatch);
}